package com.rico.deploy.service.impl;

import com.rico.deploy.entity.Clazz;
import com.rico.deploy.mapper.ClazzMapper;
import com.rico.deploy.service.ClazzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author 夏智力
 * @FileName ClazzServiceImpl
 * @date 2021/5/2 17:39
 * @Software: IntelliJ IDEA
 */
@Service
public class ClazzServiceImpl implements ClazzService {
    @Autowired
    private ClazzMapper clazzMapper;

    @Override
    public List<Clazz> selectAll(Integer page, Integer limit, String keyword) {
        Example example = new Example(Clazz.class);
        example.createCriteria()
                .andEqualTo("majorName",keyword);
        return clazzMapper.selectByExample(example);
    }

    @Override
    public Clazz selectById(Integer id) {
        return clazzMapper.selectByPrimaryKey(id);
    }

    @Override
    public int insertClazz(Clazz clazz) {
        return clazzMapper.insert(clazz);
    }

    @Override
    public int deleteClazzById(Integer id) {
        return clazzMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateClazz(Clazz clazz) {
        return clazzMapper.updateByPrimaryKey(clazz);
    }
}
